//起始时间
//1980年1月1日星期二
//前面有2个空位
//一年有365天  366天
//需要算出今年会365 还是366
var year=2019;
var month=5;
document.querySelector("#nian").innerHTML=year;
document.querySelector("#yue").innerHTML=month;
function runNian(y){
    if(y % 400 === 0||(y % 4 === 0 && y % 100 !==0)){
        return true;
    }else{
        return false;
    }
}

var days=0;
for(var i=1980;i<year;i++){
    if(runNian(i)){
        days+=366;
    }else{
        days+=365;
    }
}

console.log(days);


for(var k=1;k<month;k++){
    switch (k){
        case 1:
            days += 31;
            break;
        case 2:
            if (runNian(year)) {
                days += 29;
            } else {
                days += 28;
            }
            break;
        case 3:
            days += 31;
            break;
        case 4:
            days += 30;
            break;
        case 5:
            days += 31;
            break;
        case 6:
            days += 30;
            break;
        case 7:
            days += 31;
            break;
        case 8:
            days += 31;
            break;
        case 9:
            days += 30;
            break;
        case 10:
            days += 31;
            break;
        case 11:
            days += 30;
            break;
        case 12:
            days += 31;
    }
}

//本月
var day=0;
switch(month){
    case 1:
        day+=31;
        break;
    case 2:
        if(runNian(year)){
            day+=29;

        }else{
            day+=28;
        }
        break;
    case 3:
        day+=31;
        break;
    case 4:
        day+=30;
        break;
    case 5:
        day+=31;
        break;
    case 6:
        day+=30;
        break;
    case 7:
        day+=31;
        break;
    case 8:
        day+=31;
        break;
    case 9:
        day+=30;
        break;
    case 10:
        day+=31;
        break;
    case 11:
        day+=30;
        break;
    case 12:
        day+=31;
        break;

}
console.log(days);
//上一个月
var prevDay=0;
if(month=1){
   prevDay+=31;
}else{
    switch(month-1){
        case 1:
            prevDay+=31;
            break;
        case 2:
            if(runNian(year)){
                prevDay+=29;

            }else{
                prevDay+=28;
            }
            break;
        case 3:
            prevDay+=31;
            break;
        case 4:
            prevDay+=30;
            break;
        case 5:
            prevDay+=31;
            break;
        case 6:
            prevDay+=30;
            break;
        case 7:
            prevDay+=31;
            break;
        case 8:
            prevDay+=31;
            break;
        case 9:
            prevDay+=30;
            break;
        case 10:
            prevDay+=31;
            break;
        case 11:
            prevDay+=30;
            break;
        case 12:
            prevDay+=31;
            break;

    }

}
console.log(prevDay);
var num=42;
days += 2;
console.log(days);
var start=days % 7;
var nestDay=num-start-day;
var thisDay=new Date().getDate();
var date1=document.querySelector("#date1");
for(var j=prevDay-start+1;j<=prevDay;j++){
    date1.innerHTML+="<span class='h'>"+j+"</span>";
}
for(var kk=1;kk<=day;kk++){
    if(kk==thisDay){
        date1.innerHTML+="<span class='today'>"+kk+"</span>";
    }else{
        date1.innerHTML+="<span>"+kk+"</span>";
    }
}
for(var c=1;c<=nestDay;c++){
    date1.innerHTML+="<span class='h'>"+c+"</span>";
}
